package com.niiwoo.civet.trade.service.local.guarantee;

import com.niiwoo.civet.trade.dao.mapper.credit.CreditProjectGuaranteeMapperExt;
import com.niiwoo.civet.trade.dto.request.guarantee.GuaranteeRequestDTO;
import com.niiwoo.civet.trade.dto.response.guarantee.GuaranteeResponseDTO;
import com.niiwoo.civet.trade.enums.GuaranteeTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 担保local服务实现
 *
 * @author liming
 * @date 2018-01-19 11:38
 */
@Component
public class GuaranteeService {

    @Autowired
    private CreditProjectGuaranteeMapperExt creditProjectGuaranteeMapperExt;

    public GuaranteeResponseDTO queryTotalGuaranteeNum(GuaranteeRequestDTO requestDTO) {
        Integer totalGuaranteeNum;
        GuaranteeTypeEnum type = requestDTO.getType();
        switch (type){
            case CREDIT_LOAN :
                totalGuaranteeNum = creditProjectGuaranteeMapperExt.countTotalGuaranteeNum(requestDTO.getUserId());
                break;
            default:
                /*
                 * 目前担保只考虑信用借历史数据,其他类型的担保后续可以在此实现
                 */
                totalGuaranteeNum = 0;
                break;
        }
        GuaranteeResponseDTO responseDTO = new GuaranteeResponseDTO();
        responseDTO.setTotalGuaranteeNum(totalGuaranteeNum);
        responseDTO.setType(GuaranteeTypeEnum.CREDIT_LOAN);
        return responseDTO;
    }
}
